package observe.pojo;

import java.util.ArrayList;
import java.util.List;

//带有绑定观察者到client对象，从client对象解绑观察者的方法
public class Subject {
    private List<Observe> observeList = new ArrayList<>();
    private int status;

    public void setStatus(int status){
        this.status = status;
        notifyObserve();
    }
    public int getStatus(){
        return status;
    }
    //添加观察者
    public void attach(Observe observe){
        observeList.add(observe);
    }
    //通知观察者
    public void notifyObserve(){
        for (Observe item : observeList){
            item.update();
        }
    }

}
